package com.hao.hospital.controller;


import com.hao.hospital.service.MedicalService;
import com.jfinal.core.Controller;

public class MedicalAction extends Controller {
	
	/**
	 * 医生添加患者记录
	 * http请求方式：post
	 */
	public void addinfo(){
		String bm=getPara("title");
		String bz=getPara("url");
		String bqms=getPara("note");
		String pathogeny=""+bm+" "
						+""+bz+" "
						+""+bqms;
		System.out.println(pathogeny);
		int user_id=getParaToInt("user_id");
		int person_id=getSessionAttr("person_id");
		System.out.println("user+id"+user_id+"person+id"+person_id);
		//插入病因成功
		if(MedicalService.me().addinfo(pathogeny, user_id, person_id)){
			redirect("../admin/indexBackPage?param=4");
		}else{
			renderText("插入失败");
		}
	}
	/**
	 * 医生修改患者记录
	 *
	 */
	public void updateinfo(){
		String bm=getPara("title");
		String bz=getPara("url");
		String bqms=getPara("note");
		System.out.println("中文"+bm+bz+bqms);
		String pathogeny=""+bm+" "
				+""+bz+" "
				+""+bqms;
		int id=getParaToInt("sort");
		System.out.println("id:"+id);
		if(MedicalService.me().updateinfo(id,pathogeny)==1){
			redirect("../admin/indexBackPage?param=7");
		}else{
			renderText("插入失败");
		}
	}
	/**
	 * 通过openid获取用户病历信息
	 */
	public void getinfo(){
		String openid=getSessionAttr("openid");
		//String openid=getPara("openid");
		//String openid="oYwN7vwVkZdAS81zv45kU9eGMCKQ";
		renderJson(MedicalService.me().medicalInfo_get(openid));
	}
}
